package Model;

import java.awt.Color;

public class Privilege {
	private int _privilege;
	private Color _privilegeColor;
	
	public static int Admin = 0;
	private static Color AdminColor = Color.RED;

	public static int Utilisateur = 1; 
	private static Color UtilisateurColor = Color.GREEN;
	
	public static int Invite = 2; 
	private static Color InviteColor = Color.LIGHT_GRAY;
	
	public Privilege(int privilege) {
		_privilege = privilege;
		
		if(_privilege == Admin)
			_privilegeColor = AdminColor;
		else if(_privilege == Utilisateur)
			_privilegeColor = UtilisateurColor;
		else if(_privilege == Invite)
			_privilegeColor = InviteColor;
		else {
			try {
				throw new Exception("Unknown rights " + _privilege);
			} catch (Exception e) {
				e.printStackTrace();
			} 
		}
	}
	
	public Color getColor() {
		return _privilegeColor;
	}
	
	public boolean isAdmin() {
		return _privilege == Admin;
	}
	
	public String toString() {
		if(_privilege == Admin)
			return "Administrateur";
		else if(_privilege == Utilisateur)
			return "Utilisateur";
		else
			return "Invité";
	}
}
